package group2.service.impl;

import group2.mapper.BookMapper;
import group2.model.Book;
import group2.model.BookType;
import group2.service.IBookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 薛献军
 * @date 2020/8/18 9:29
 */
@Service("bookService")
public class BookServiceImpl implements IBookService {

    @Autowired
    BookMapper bookMapper;



    /**
     * 关键词搜索，分页显示
     * @param condition
     * @return
     */
    @Override
    public List<Book> search(String condition) {
        return this.bookMapper.search(condition);
    }

    /**
     * 查询所有书籍类型信息
     * @return
     */
    @Override
    public List<BookType> allBookTypes() {
        return this.bookMapper.allBookTypes();
    }


    /**
     * 按书籍号查询书籍详情
     * @param book_id
     * @return
     */
    @Override
    public Book selectByBookId(int book_id) {
        return this.bookMapper.selectByBookId(book_id);
    }

    /**
     * 分类导航/分页显示
     * @param typeId
     * @return
     */
    @Override
    public List<Book> selectByTypeId(int typeId) {
        return this.bookMapper.selectByTypeId(typeId);
    }

    /**
     * 新书上架
     */
    @Override
    public List<Book> newBooks() {
        return this.bookMapper.newBooks();
    }

    /**
     * 特价精选，按discount升序排序，选前10个
     * @return
     */
    @Override
    public List<Book> discountBooks() {
        return this.bookMapper.discountBooks();
    }

    @Override
    public List<Book> goodBooks() {
        return this.bookMapper.goodBooks();
    }
}
